/*
 * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
 * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
 */
package com.yxw.live_vod_boot.jobs;

import cn.hutool.core.util.StrUtil;
import com.yxw.live_vod_boot.utils.RedisPipeAccessObject;
import com.yxw.yxnet_cd_center.common.exception.BaseException;
import javax.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.dao.DataAccessException;
import org.springframework.data.redis.connection.RedisConnection;
import org.springframework.data.redis.core.RedisCallback;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import com.yxw.live_vod_facade.constant.LiveShopConstant;
/*** 
 * 用于队列服务器的控制管理
*@author hjx
*@date 2023/12/26 14:06:22
*@update 2023/12/26 14:06:22
*
**/
@Slf4j
@Component
@EnableScheduling
public class HostManagerJobs {
    @Resource
    private RedisTemplate redisTemplate;
    
    //@Scheduled(fixedRate = 4000)
    public void keepAliveJob()
    {
        redisTemplate.executePipelined((RedisCallback<Object>) new RedisCallback<Object>() {
            @Override
            public Object doInRedis(RedisConnection connection) throws DataAccessException {
                connection.openPipeline();
                try
                {
                    //connection.set(redisTemplate.getKeySerializer().serialize(LiveShopConstant.LIVEVOD_LIVE_HOSTMANAGER_LINKHASHMAP_KEY),redisTemplate.getValueSerializer().serialize(oRedisPipeAccessObject.getRedisValue()));
                    //connection.hSet(redisTemplate.getKeySerializer().serialize(oRedisPipeAccessObject.getRedisKey()), redisTemplate.getKeySerializer().serialize(oRedisPipeAccessObject.getRedisInnerHashMapKey()), redisTemplate.getValueSerializer().serialize(oRedisPipeAccessObject.getRedisValue()));
                }
                catch(Exception e)               
                {
                    log.error("keepAliveJob命令异常:====================================>{}", e);
                    throw new BaseException("keepAliveJob命令异常:"+e.getMessage());
                }
                finally
                {
                    connection.close();
                }
                return null;
            }
        });    
    }
    private void LoadOtherServverData()
    {
    
    }
}
